local yitian = fk.CreateSkill {
  name = "inker_yitian",
}

yitian:addEffect("active", {
  anim_type = "control",
  prompt = "#inker_yitian",
  max_phase_use_time = 1,
  card_num = 0,
  card_filter = Util.FalseFunc,
  target_num = 1,
  target_filter = function(self, player, to_select, selected)
    return #selected == 0 and not to_select:isKongcheng()
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]

    room:syncPlayerClientCards(target)
    local handcards = target:getCardIds("h")
    local piles = room:getNCards(#handcards)

    room:swapCardsWithPile(target, handcards, piles, yitian.name, "Top", nil, player)
  end
})
yitian:addEffect(fk.Damaged, {
  anim_type = "masochism",
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if not table.find(room:getAlivePlayers(false), function (p)
      return not p:isKongcheng()
    end) then return end

    local _, dat = room:askToUseActiveSkill(player, {
      skill_name = yitian.name,
      prompt = "#inker_yitian",
      skip = true,
    })
    if dat then
      event:setCostData(self, { tos = dat.targets })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local dat = event:getCostData(self)
    Fk.skills[yitian.name]:onUse(player.room, SkillUseData:new {
      from = player,
      tos = dat.tos,
    })
  end
})

Fk:loadTranslationTable{
  ["inker_yitian"] = "弈天",
  [":inker_yitian"] = "出牌阶段限一次或你受到伤害后，你可以将一名角色的<a href=':inker_yitian_order'>所有手牌</a>与牌堆顶等量张牌交换。",
  [":inker_yitian_order"] = "按照目标客户端手牌从左至右的方向，为牌堆顶最上至最下，即移动后，最左端手牌为牌堆顶牌",

  ["#inker_yitian"] = "弈天：将一名角色的所有手牌与牌堆顶等量张牌交换",

  ["$inker_yitian1"] = "轻舟载浊酒，此去，我欲借箭十万。",
  ["$inker_yitian2"] = "主公有多大胆略，亮便有多少谋略。",
}

return yitian